<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class m_login extends CI_Model {

    public function getLoginData($usr, $pwd) {
        $u = mysql_real_escape_string($usr);
        $p = md5(mysql_real_escape_string($pwd));
        $q_cek_login = $this->db->get_where('manajemen', array('username' => $u, 'password' => $p));
        if (count($q_cek_login->result()) > 0) {
            foreach ($q_cek_login->result() as $qck) {
                foreach ($q_cek_login->result() as $qcd) {
                    $sess_data['logged_in'] = 'yesGetMeLogin';
                    $sess_data['username'] = $qcd->username;
                    //$sess_data['nama_pengguna'] = $qcd->nama_pengguna;
                    $this->session->set_userdata($sess_data);
                }
                header('location:' . base_url() . 'news');
            }
        } else {
            $this->session->set_flashdata('result_login', 'Username atau Password yang anda masukkan salah.');
            header('location:' . base_url() . 'index.php/login');
        }
    }

}

?>